import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:Exercise
 * User:22954
 * Date:2024-01-02
 * Time:0:00
 */
public class Test {
    public static void main(String[] args) {
//        exercise1();//根据年龄，判断当前人的属性
//        exercise2();//判断一个数是否是素数
//        exercise3();//输出1-100中的素数
//        exercise4();//输出1000-2000中的闰年
//        exercise5();//打印9*9乘法表
//        exercise6();//求出两个正整数的最大公约数
        exercise7();//打印100-999的水仙花数
//        int a=exercise8(-1);//函数返回参数二进制中1的个数
//        exercise9();//获取一个数二进制序列中所有的奇数位和偶数位，分别打印
//        exercise10();//猜数字游戏
    }

    public static void exercise1() {
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入某人的年龄：");
        int age = scan.nextInt();
        if (age <= 18)
            System.out.println("这个人是少年");
        else if (age <= 28)
            System.out.println("这个人是青年");
        else if (age <= 55)
            System.out.println("这个人是中年");
        else
            System.out.println("这个人是老年");
    }

    public static void exercise2() {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
//        int a = (int) Math.sqrt(x);
        boolean judge = true;
//        System.out.println(a);
        for (int i = 2; i <= (int) Math.sqrt(x); i++) {
            if (x % i == 0) {
                System.out.println(x + "不是素数");
                judge = false;
                break;
            }
        }
        if (judge)
            System.out.println(x + "是素数");
    }

    public static void exercise3() {
        for (int i = 1; i <= 100; i++) {
            boolean judge = true;
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    judge = false;
                    break;
                }
            }
            if (judge)
                System.out.print(i + " ");
        }
    }

    public static void exercise4() {
        int count = 0;
        for (int i = 1000; i <= 2000; i++) {
            if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
                System.out.print(i + " ");
                count++;
            }
            if (count == 20) {
                System.out.println();
                count = 0;
            }
        }
    }

    public static void exercise5() {
        //用printf，C中方法
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.printf("%d*%d=%-2d ", j, i, i * j);
            }
            System.out.println();
        }
        //用\t格式化对齐
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + (j * i) + "\t");
            }
            System.out.println();
        }
    }

    public static void exercise6() {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int a = x, b = y;
        if (x < y) {
            a = y;
            b = x;
        }
        //辗转相除法
        while (true) {
            if (a % b == 0) {
                System.out.println(x + "和" + y + "的最大公倍数为:" + b);
                break;
            }
            int tmp = a % b;
            a = b;
            b = tmp;
        }
        //穷举法
        for (int i = b; i > 0; i--) {
            if (x % i == 0 && y % i == 0) {
                System.out.println(x + "和" + y + "的最大公倍数为:" + i);
                break;
            }
        }
    }

    public static void exercise7() {
        int[] arr = new int[3];
        for (int i = 100; i < 1000; i++) {
            int sum=0;
            for (int j = 0; j < 3; j++) {
                arr[j]=(int)(i/Math.pow(10,j)%10);
                sum+=(int)Math.pow(arr[j],3);
            }
            if(sum==i){
                System.out.print(i+" ");
            }
        }
        System.out.println();
    }
    public static int exercise8(int x){
        int count=0;
//        for (int i = 0; i < 32; i++) {
//            if(((x>>i)&1)==1){
//                count++;
//            }
//        }
        //简化计算
//        while(x!=0){
//            if((x&1)==1){
//                count++;
//            }
//            x=x>>>1;
//        }
        //进一步简化计算
        while(x!=0){
            x&=(x-1);
            count++;
        }
        System.out.println(count);
        return count;
    }
    public static void exercise9(){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int[] odd=new int[16];
        int[] even=new int[16];
        int n1,n2;
        n1=n2=0;
        for (int i = 1; i <= 32; i++) {
            if(i%2==1){
                odd[n1++]=x&1;
            }else{
                even[n2++]=x&1;
            }
            x>>=1;
        }
        for (int i = 15; i >=0; i--) {
            System.out.print(odd[i]+" ");
        }
        System.out.println();
        for (int i = 15; i >=0; i--) {
            System.out.print(" "+even[i]);
        }
    }
    public static void exercise10(){
        Scanner scan=new Scanner(System.in);
        Random rand=new Random();
        int x= rand.nextInt(101);
//        System.out.println(x);
        int n=101;
        while(n!=x){
            System.out.print("请输入0-100的数字：");
            n=scan.nextInt();
            if(n>x){
                System.out.println("猜大了");
            }
            else if(n<x){
                System.out.println("猜小了");
            }

        }
        System.out.println("猜对了");
    }
}
